# 登录页

from base.page_base import BasePage
from selenium.webdriver.common.by import By


class ClientLogin(BasePage):
    """登录页面"""

    #元素定位
    __username = By.ID, 'keywords' # 用户名
    __password = By.ID, 'password' # 密码
    __login_btn = By.ID, 'login-btn' # 登录按钮
    __assert_success_text = By.XPATH, '//span[text()="登录成功"]' # 登录成功
    __assert_fail_text = By.XPATH, '//span[@class="ng-binding"]' # 登陆失败


    def open_url(self): # 打开登录页面
        return self.driver.get('http://121.43.169.97:8081/common/member/login')
    def input_username(self,username): # 输入用户名
        self.base_input(self.__username, username)

    def input_password(self, password): # 输入密码
        self.base_input(self.__password, password)

    def click_login_btn(self): # 点击登录按钮
        self.base_click(self.__login_btn)

    def assert_login_success(self): # 断言登录成功
        return self.base_get_text(self.__assert_success_text)

    def assert_login_fail(self): # 断言登录失败 --> 密码错误
        return self.base_get_text(self.__assert_fail_text)


    def client_login(self, username, password): # 登录
        self.input_username(username)
        self.input_password(password)
        self.click_login_btn()


